<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" />
    <ex_super_table_page v-bind="option" ref="SuperTablePage">
    </ex_super_table_page>
    <ex_super_dialog_form ref="detail_dialog" v-bind="detail_dialog" noSubmit>
    </ex_super_dialog_form>
  </div>
</template>

<script>
import business_function from "@/common/business_function"

import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import router_params from '@/mixin/router_params';
let emitKey = 'outbound>pack_weigh_record'
import emitOnFunction from '@/mixin/emit-on-function';
export default {
  title: "label_pack_measure_weight_record",
  mixins: [superTablePageFunction, router_params, emitOnFunction(emitKey), page_table_model_manage],
  components: {},
  data() {
    return {
      option: {
        search: {
          model: [
            { label: "label_package_code", key: "packingNo", },
            { label: 'label_srm_supplier_name', key: 'supplierName', },

            { label: "label_customer_name", key: "customerName", },
            { label: "label_operate_user", key: "operatingUser", },
            { label: "label_sku", key: "skuId", type: 'sku_selec_input', },
            {
              label: "label_create_time", key: 'gmtCreateForm', type: 'date-picker', attrs: { type: 'datetime' },
              render: (h, { data, item }) => {
                const limitKey = 'gmtCreateTo'; const value = data[item.key]; const limitValue = data[limitKey];
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_start_time"
                  attrs={{ type: 'datetime' }} pickerOptions={{ disabledDate: date => { return limitValue ? (limitValue < date.getTime()) : false } }}
                />)
              }
            },
            {
              label: "~", key: 'gmtCreateTo', type: 'date-picker', attrs: { type: 'datetime' },
              render: (h, { data, item }) => {
                const limitKey = 'gmtCreateForm'; const value = data[item.key]; const limitValue = data[limitKey];
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_end_time"
                  attrs={{ type: 'datetime', 'default-time': '23:59:59' }} pickerOptions={{ disabledDate: date => { return limitValue ? (limitValue > date.getTime()) : false } }}
                />)
              }
            },
          ],
        },
        actionExtra: [
          {
            label: 'label_export', click: this.exportRecord
          },
        ],
        table: {
          url: "/wms-api/outbound/OutboundPickingWeighRecordRpc/selectSingleListPage.json",
          model: this.init_table_model(),
        }
      },
      detail_dialog: {
        customClass: 'dialog_big',
        detailUrl: "/wms-api/outbound/OutboundPickingWeighRecordRpc/selectListByPackingNo.json",

        form: {
          model: [
            {
              key: 'rows', formType: "itemTable",
              height: 400,
              model: [
                { key: 'packingNo', label: 'label_package_code', 'min-width': 120, 'show-overflow-tooltip': true, },
                { key: 'customerName', label: 'label_customer_info', 'width': 120, 'show-overflow-tooltip': true, },
                {
                  key: 'supplierName', label: 'label_pms_supply', 'width': 100, 'show-overflow-tooltip': true
                },
                {
                  key: 'orderNo', label: 'label_order_code', 'width': 100, 'show-overflow-tooltip': true
                },
                {
                  key: 'pieceCount', label: 'label_tms_track_pkgs', 'width': 100, 'show-overflow-tooltip': true
                },
                {
                  key: 'volume', label: 'label_volume', 'width': 100, 'show-overflow-tooltip': true
                },

                {
                  key: 'weight', label: 'label_weight', 'width': 100, 'show-overflow-tooltip': true
                },
                {
                  key: 'gmtCreate', label: 'label_operate_time', 'width': 130, 'show-overflow-tooltip': true,
                  formatter: (r, c, v) => this.$dateFormat(v)
                },
                {
                  key: 'creator', label: 'label_operate_user', 'width': 130, 'show-overflow-tooltip': true
                },
              ],
            },

          ],
        }
      },
    };
  },

  mounted() {

  },

  methods: {

    option_table_model() {
      return [

        { key: 'packingNo', label: 'label_package_code', 'min-width': 120, 'show-overflow-tooltip': true, },

        { key: 'customerName', label: 'label_customer_info', 'width': 120, 'show-overflow-tooltip': true, },


        {
          key: 'supplierName', label: 'label_pms_supply', 'width': 100, 'show-overflow-tooltip': true
        },
        {
          key: 'orderNo', label: 'label_order_code', 'width': 100, 'show-overflow-tooltip': true
        },

        {
          key: 'pieceCount', label: 'label_tms_track_pkgs', 'width': 100, 'show-overflow-tooltip': true
        },

        {
          key: 'volume', label: 'label_volume', 'width': 100, 'show-overflow-tooltip': true
        },

        {
          key: 'weight', label: 'label_weight', 'width': 100, 'show-overflow-tooltip': true
        },
        {
          key: 'operCount', label: 'label_operate_times', 'width': 100, 'show-overflow-tooltip': true
        },
        {
          key: 'gmtCreate', label: 'label_operate_time', 'width': 130, 'show-overflow-tooltip': true,
          formatter: (r, c, v) => this.$dateFormat(v)
        },
        {
          key: 'creator', label: 'label_operate_user', 'width': 130, 'show-overflow-tooltip': true
        },
        {
          type: 'operate', width: 200, fixed: 'right', operate: [
            {
              label: 'label_view_detail', click: (row) => {
                this.$refs.detail_dialog.showNew({
                  title: this.$t('label_pack_measure_weight_detail') + ":" + row.packingNo,
                  params: {
                    packingNo: row.packingNo
                  },
                })
              },
            },
          ]
        }
      ]
    },
    exportRecord() {
      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: this.$refs.SuperTablePage.getSearchFormData(),
        model: this.option.search.model,
        callback: (selection, data) => {
          let params = data
          this.$functionCommon({
            url: "/wms-api/outbound/OutboundPickingWeighRecordRpc/exportOrderDetailExcel.json",
            data: params, system: "wms",
          })
        }
      })

    },
  }
};

</script>
<style></style>
